# frozen_string_literal: true

{{#generated_src_warning}}
{{generated_src_warning}}
{{/generated_src_warning}}
module {{module_name}}
  # Endpoint parameters used to influence endpoints per request.
  #
  {{#parameters}}
  {{documentation}}
  {{/parameters}}
  EndpointParameters = Struct.new(
    {{#parameters}}
    :{{key}},
    {{/parameters}}
    {{^parameters}}
    nil
    {{/parameters}}
  ) do
    include Aws::Structure

    # @api private
    class << self
      PARAM_MAP = {
        {{#parameters}}
        '{{name}}' => :{{key}},
        {{/parameters}}
      }.freeze
    end

    def initialize(options = {})
      {{#parameters}}
      self[:{{key}}] = options[:{{key}}]
      {{#default?}}
      self[:{{key}}] = {{{default}}} if self[:{{key}}].nil?
      {{/default?}}
      {{#validate_required?}}
      if self[:{{key}}].nil?
        raise ArgumentError, "Missing required EndpointParameter: :{{key}}"
      end
      {{/validate_required?}}
      {{/parameters}}
    end

    def self.create(config, options={})
      new({
        {{#config_parameters}}
        {{key}}: {{{value}}},
        {{/config_parameters}}
      }.merge(options))
    end
  end
end
